package com.example.push.service.impl;

import com.example.push.domain.MessageRecord;
import com.example.push.repository.MessageRecordRepository;
import com.example.push.service.MessageService;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@RequiredArgsConstructor
public class MessageServiceImpl implements MessageService {

    private final MessageRecordRepository messageRecordRepository;

    @Override
    @Transactional(readOnly = true)
    public Page<MessageRecord> findAll(Pageable pageable) {
        return messageRecordRepository.findAll(pageable);
    }

    @Override
    @Transactional(readOnly = true)
    public MessageRecord findByMessageId(String messageId) {
        return messageRecordRepository.findByMessageId(messageId);
    }

    @Override
    @Transactional
    public void deleteMessage(Long id) {
        messageRecordRepository.deleteById(id);
    }
}